package com.jianZhiOffer;

import java.util.ArrayList;
import java.util.List;

public class Solution57 {
    public int[][] findContinuousSequence(int target) {
        List<int[]> resList = new ArrayList<>();
        int i = 1;
        int j = 2;
        int sum = 3;
        int num = (target + 1) >> 1;
        while (i < j && j <= num) {
            if (sum == target) {
                int[] tmp = new int[j - i + 1];
                for (int k = i; k < j + 1; k++) {
                    tmp[k - i] = k;
                }
                resList.add(tmp);
            }
            if (sum >= target) {
                sum -= i;
                i++;
            } else {
                j++;
                sum += j;
            }
        }
        return resList.toArray(new int[resList.size()][]);
    }
}
